home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.06 Jun 91 / Split Button Code / Split Button Stack / stack.txt < prev   
Encoding:
Text File  |  1990-08-04  |  8.0 KB  |  247 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2668
  12. -- card count: 1
  13. -- first card id: 3851
  14. -- list block id: 3359
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 14848 bytes
  21. -- stack block size: 7168 bytes
  22. -- created by hypercard version: 0x01208000
  23. -- compacted by hypercard version: 0x01208000
  24. -- modified by hypercard version: 0x01208000
  25. -- opened by hypercard version: 0x01208000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68.  
  69. --Copyright ¬© 1990 MacTutor
  70.  
  71. --Written by Carl J. Manaster
  72. --August, 1990
  73.  
  74. --message split
  75. --syntax: split(orientation,topMessage,bottomMessage)
  76. ----------where: orientation is "/" or "\"
  77. ----------topMessage is message to be called if click
  78. --------------------------was in top half of target
  79. ----------bottomMessage is message to be called if click
  80. --------------------------was in bottom half of target
  81.  
  82. on split
  83.   put param(2) into topMessage
  84.   put param(3) into bottomMessage
  85.   put (the bottom of the target) - (the clickV) into vDiff
  86.   if param(1) is "/"
  87.   then put (the clickH) - (the left of the target) into hDiff
  88. else put (the right of the target) - (the clickH) into hDiff
  89. put vDiff*(the width of the target)>hDiff*(the height of the target) into doTop
  90.  
  91. if doTop
  92. then send topMessage to target
  93. else send bottomMessage to target
  94.  
  95. end split
  96. ---------------------------------------------------------------------
  97.  
  98.  
  99. --message makePolyButton
  100. --syntax: makePolyButton(inMessage,outMessage)
  101. ----------inMessage is message to be called by clicks
  102. --------------------------within the polyButton
  103. ----------outMessage is message to be called by clicks
  104. --------------------------outside the polyButton
  105.  
  106. on makePolyButton inMessage,outMessage
  107.   put empty into pointList
  108.   choose line tool
  109.   set the cursor to cross
  110.   wait until the mouseClick
  111.   put the clickLoc into pointList
  112.  
  113.   repeat
  114.     wait until the mouseClick
  115.     put return & the clickLoc after pointList
  116.     put the number of lines of pointList into count
  117.     drag from (line count-1 of pointList) to (line count of pointList)
  118.     if abs(item 1 of last line of pointList - item 1 of first line of pointList)<2 and abs(item 2 of last line of pointList - item 2 of first line of pointList)<2 then exit repeat
  119.   end repeat
  120.  
  121.   put line 1 of pointList into last line of pointList
  122.   put the number of card buttons into cbCount
  123.   set lockScreen to true
  124.   doMenu revert
  125.   choose button tool
  126.  
  127.   put item 1 of line 1 of pointList into maxV
  128.   put item 1 of line 2 of pointList into maxPenV
  129.   put item 1 of line 1 of pointList into minV
  130.   put item 1 of line 2 of pointList into minPenV
  131.  
  132.   put item 2 of line 1 of pointList into maxH
  133.   put item 2 of line 2 of pointList into maxPenH
  134.   put item 2 of line 1 of pointList into minH
  135.   put item 2 of line 2 of pointList into minPenH
  136.  
  137.   repeat with i=2 to count
  138.  
  139.     get item 1 of line i of pointList
  140.     if it > maxPenV then                --find the largest
  141.       if it > maxV then                 --and second largest v
  142.         put maxV into maxPenV
  143.         put it into maxV
  144.       else
  145.         put it into maxPenV
  146.       end if
  147.     end if
  148.  
  149.     if it < minPenV then                --find the smallest
  150.       if it < minV then                 --and second smallest v
  151.         put minV into minPenV
  152.         put it into minV
  153.       else
  154.         put it into minPenV
  155.       end if
  156.     end if
  157.  
  158.     get item 2 of line i of pointList
  159.     if it > maxPenH then                --find the largest
  160.       if it > maxH then                 --and second largest h
  161.         put maxH into maxPenH
  162.         put it into maxH
  163.       else
  164.         put it into maxPenH
  165.       end if
  166.     end if
  167.  
  168.     if it < minPenH then                --find the smallest
  169.       if it < minH then                 --and second smallest h
  170.         put minH into minPenH
  171.         put it into minH
  172.       else
  173.         put it into minPenH
  174.       end if
  175.     end if
  176.  
  177.   end repeat
  178.  
  179.   add 1 to cbCount       --create the interior button
  180.   doMenu "new button"
  181.   set the style of card button cbCount to transparent
  182.   set the showName of card button cbCount to false
  183.   set the autoHilite of card button cbCount to false
  184.   set the rect of card button cbCount to minPenV,minPenH,maxPenV,maxPenH
  185.   put "on mouseUp" into theScript
  186.   put return & inMessage after theScript
  187.   put return & "end mouseUp" after theScript
  188.   set the script of card button cbCount to theScript
  189.  
  190.   repeat with i=1 to count-1
  191.     add 1 to cbCount     --create the edge buttons
  192.     set the cursor to busy
  193.     put line i of pointList into firstPoint
  194.     put line (i+1) of pointList into secondPoint
  195.     doMenu "new button"
  196.     set the name of card button cbCount to "split" && i
  197.  
  198.     --determine the co√∂rdinates of the button:
  199.  
  200.     if (item 1 of firstPoint) < (item 1 of secondPoint) then
  201.       put item 1 of firstPoint into top
  202.       put item 1 of secondPoint into bottom
  203.     else
  204.       put item 1 of secondPoint into top
  205.       put item 1 of firstPoint into bottom
  206.     end if
  207.     if (item 2 of firstPoint) > (item 2 of secondPoint) then
  208.       put item 2 of firstPoint into right
  209.       put item 2 of secondPoint into left
  210.     else
  211.       put item 2 of secondPoint into right
  212.       put item 2 of firstPoint into left
  213.     end if
  214.  
  215.     set the rect of card button cbCount to top,left,bottom,right
  216.     set the style of card button cbCount to transparent
  217.     set the showName of card button cbCount to false
  218.     set the autoHilite of card button cbCount to false
  219.  
  220.     --determine the orientation of the "split" of the button:
  221.  
  222.     put "on mouseUp" into theScript
  223.  
  224.     if (item 1 of firstPoint) > (item 1 of secondPoint) then
  225.       if (item 2 of firstPoint) > (item 2 of secondPoint) then
  226.         put return & "split " & quote & "\" & quote & "," & inMessage & "," & outMessage after theScript
  227.       else
  228.         put return & "split " & quote & "/" & quote & "," & inMessage & "," & outMessage after theScript
  229.       end if
  230.     else
  231.       if (item 2 of firstPoint) > (item 2 of secondPoint) then
  232.         put return & "split " & quote & "/" & quote & "," & outMessage & "," & inMessage after theScript
  233.       else
  234.         put return & "split " & quote & "\" & quote & "," & outMessage & "," & inMessage after theScript
  235.       end if
  236.     end if
  237.  
  238.     put return & "end mouseUp" after theScript
  239.  
  240.     set the script of card button cbCount to theScript
  241.   end repeat
  242.  
  243.   choose browse tool
  244. end makePolyButton
  245. ---------------------------------------------------------------------
  246.  
  247.